$(function () {
    // 获取用户信息
    var loading = weui.loading('loading', {
        className: 'custom-classname'
    });
    var result = Model.user.getUserInfo();
    if (!sessionStorage.getItem('hmdj_stopError')) {
        sessionStorage.setItem('hmdj_stopError', true);
    } else {
        if (result.code) {
            Common.fn.formatOutput(result);
            loading.hide();
            return false;
        }
    }
    // 设置消息红点
    var isMessage = result.data.message;
    if(isMessage) {
        $('#message-circle').addClass('count-icon');
        $('#message-circle').text(result.data.message_count);
    }else {
        $('#message-circle').removeClass('count-icon');
    }
    // 设置礼品订单红点
    var isCount = result.data.count
	if (isCount > 0) {
		$('#gift-circle').addClass('count-icon')
		$('#gift-circle').text(isCount)
	} else {
		$('#gift-circle').removeClass('count-icon')
	}
    $(".portrait-img").attr('src', result.data.photo);
    $(".m-shop-vendor-info h3").text(result.data.nickname);
    $(".vendor-level").text('v' + result.data.grade);
    result.data.auth ? $('.auth').text('已认证') : $('.auth').text('未认证');
    if (!result.data.auth) {
        $('.auth').on('click', function () {
            location.href = 'authentication.html';
        });
    }else {
        $('.auth').on('click', function() {
            location.href = 'authentication2.html';
        });
    }
    $(".fans-num").text(result.data.fans);
    $(".attention-num").text(result.data.attention);
    $('.bond').text(result.data.bond + '元');
    $(".credits").text(result.data.credits + '分');
    loading.hide();
    //保证金按钮
    $('.bond').on('click', function () {
        location.href = 'bond.html';
    });
    // 联系客服
    $('#showTooltips').on('click', function() {
        weui.confirm('请关注“红木大集文玩”公众号 <br> 在公众号内留言', {
			title: '',
			buttons: [
				{
					label: '确定',
					type: 'default',
					onClick: function() {
						
					},
				},
				{
					label: '联系电话',
					type: 'primary',
					onClick: function() {
						window.location.href = 'tel:13931608285';
					},
				},
			],
		});
    });
    // 编辑信息
    $('#edit-info').on('click', function() {
        sessionStorage.setItem('hmdj_photo', $('.portrait-img').attr('src'));
        sessionStorage.setItem('hmdj_nickname', $('.m-shop-vendor-info h3').text());
        location.href = 'edit_info.html';
    });
});